home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1986 April
/
Ahoy_Magazine_86-04_1986_Double_L.d64
/
printing perm
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
271b
|
12 lines
1 rem
2 rem problem #24-1 :
3 rem printing permutations
4 rem solution by
5 rem allan flippin
6 rem.
100 clr:input n:dimc(n-1):for i=1 to n:s$=s$+chr$(48+i):next
110 i=n-1:print s$,
120 s$=left$(s$,i-1)+right$(s$,n-i)+mid$(s$,i,1)
130 c(i)=c(i)+1:if c(i)<=n-i goto 110
140 c(i)=0:if i>1 then i=i-1 : goto 120